home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / putmsg.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  102 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: putmsg.c,v 1.4 1996/08/13 13:56:05 digulla Exp $
  4.     $Log: putmsg.c,v $
  5.     Revision 1.4  1996/08/13 13:56:05  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:15  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "exec_intern.h"
  17. #include <aros/libcall.h>
  18.  
  19. /*****************************************************************************
  20.  
  21.     NAME */
  22.     #include <exec/ports.h>
  23.     #include <clib/exec_protos.h>
  24.  
  25.     __AROS_LH2(void, PutMsg,
  26.  
  27. /*  SYNOPSIS */
  28.     __AROS_LHA(struct MsgPort *, port,    A0),
  29.     __AROS_LHA(struct Message *, message, A1),
  30.  
  31. /*  LOCATION */
  32.     struct ExecBase *, SysBase, 61, Exec)
  33.  
  34. /*  FUNCTION
  35.     Sends a message to a given message port. Messages are not copied
  36.     from one task to another but must lie in shared memory instead.
  37.     Therefore the owner of the message may generally not reuse it before
  38.     it is returned. But this depends on the two tasks sharing the message.
  39.  
  40.     INPUTS
  41.     port    - Pointer to messageport.
  42.     message - Pointer to message.
  43.  
  44.     RESULT
  45.  
  46.     NOTES
  47.     It is legal to send a message from within interrupts.
  48.  
  49.     Messages may either trigger a signal at the owner of the messageport
  50.     or raise a software interrupt, depending on port->mp_Flags&PF_ACTION.
  51.  
  52.     EXAMPLE
  53.  
  54.     BUGS
  55.  
  56.     SEE ALSO
  57.     WaitPort(), GetMsg()
  58.  
  59.     INTERNALS
  60.  
  61.     HISTORY
  62.  
  63. ******************************************************************************/
  64. {
  65.     __AROS_FUNC_INIT
  66.  
  67.     /*
  68.     Messages may be sent from interrupts. Therefore the message list
  69.     of the message port must be protected with Disable().
  70.     */
  71.     Disable();
  72.  
  73.     /* Set the node type to NT_MESSAGE == sent message. */
  74.     message->mn_Node.ln_Type=NT_MESSAGE;
  75.  
  76.     /* Add it to the message list. */
  77.     AddTail(&port->mp_MsgList,&message->mn_Node);
  78.  
  79.     /* And trigger the action. */
  80.     switch(port->mp_Flags&PF_ACTION)
  81.     {
  82.     case PA_SIGNAL:
  83.         /* Send the signal */
  84.         Signal((struct Task *)port->mp_SigTask,1<<port->mp_SigBit);
  85.         break;
  86.  
  87.     case PA_SOFTINT:
  88.         /* Raise a software interrupt */
  89.         Cause((struct Interrupt *)port->mp_SoftInt);
  90.         break;
  91.  
  92.     case PA_IGNORE:
  93.         /* Do nothing. */
  94.         break;
  95.     }
  96.  
  97.     /* All done. */
  98.     Enable();
  99.     __AROS_FUNC_EXIT
  100. }
  101.  
  102.